package pers.wwz.study.redisson;

import org.redisson.Redisson;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.redisson.config.*;

@SpringBootApplication
public class SpringBootRedissonApplication {

    @Value("${config.redis.host}")
    private String host;
    @Value("${config.redis.port}")
    private String port;

    @Value("${config.redis.password}")
    private String password;

    @Bean
    public Redisson redisson() {
        // 此为单机模式
        Config config = new Config();
        config.useSingleServer().setAddress("redis://"+host+":"+port).setDatabase(0).setPassword(password);
        return (Redisson) Redisson.create(config);
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringBootRedissonApplication.class, args);
    }

}
